package com.eling.elcms.travel.service.impl;

import com.eling.elcms.core.service.ServiceLocator;
import com.eling.elcms.core.service.impl.GenericManagerImpl;
import com.eling.elcms.travel.dao.IApprovalRuleRegisterDao;
import com.eling.elcms.travel.model.ApprovalRuleRegister;
import com.eling.elcms.travel.service.IApprovalRule;
import com.eling.elcms.travel.service.IApprovalRuleRegisterService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Map;


@Service
public class ApprovalRuleRegisterServiceImpl extends GenericManagerImpl<ApprovalRuleRegister, Long> implements IApprovalRuleRegisterService  {
	IApprovalRuleRegisterDao approvalRuleRegisterDao;
	@Autowired
	public void setDao(IApprovalRuleRegisterDao dao) {
		this.dao = dao;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Map<String, String> findCandidatePara(ApprovalRuleRegister cond) {
		if(StringUtils.isNotBlank(cond.getRuleClass())){
			IApprovalRule approvalRule =ServiceLocator.getService(cond.getRuleClass());
			return approvalRule.candidatePara();
		}else{
			return Collections.EMPTY_MAP;
		}
	}
}
